<template>
  <div>
    <el-button size="small" type="primary" style="margin-right: 10px;" @click="edit(data)">
      编辑</el-button>
    <el-button size="small" type="primary" style="margin-right: 10px;" @click="uploadpass(data)">
      改密</el-button>
    <el-popconfirm title="确定删除本条数据吗?" @confirm="confirmEvent" @cancel="cancelEvent" confirm-button-text="确定"
      placement="top" cancel-button-text="取消">
      <template #reference>
        <el-button size="small">删除</el-button>
      </template>
    </el-popconfirm>

  </div>
</template>
<script setup lang="ts">

import { crud, onDelete } from '/@/crud/crud'
import { userinfo } from '/@/api/system/user';
import { Delete, Edit, DocumentAdd, Download, Upload } from '@element-plus/icons-vue'
const props = defineProps({
  data: { type: Object },
});

const emit = defineEmits(['uploadpassdata'])
const confirmEvent = () => {
  console.log('confirm!', props.data.id)

  onDelete([props.data.id])
}
const cancelEvent = () => {
  console.log('cancel!')
}

const uploadpass = (data) => {
  emit("uploadpassdata", data)


}
const edit = (data) => {
  userinfo({ userId: data.id }).then((res: any) => {
    delete res.data.departmentName
    delete res.data.updatedAt
    delete res.data.psalt
    delete res.data.headImg
    delete res.data.createdAt
    // delete res.data.updatedAt
    crud.toEdit(res.data)
  })

  // crud.toEdit(data)
}
</script>